package com.lx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket creatApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .apiInfo(apiInfo1())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lx.controller"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("新闻咨询API")
                .description("") .title("新闻咨询API文档")
                .description("新闻咨询接口文档说明")
                .contact(new Contact("新闻咨询开发人员", "http://www.example.com/", "developer@example.com"))
                .version("1.0")
                .build();
    }

//    @Bean
//    public Docket creatApi1() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .apiInfo(apiInfo1())
//                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.lx.controller"))
//                .paths(PathSelectors.any())
//                .build()
//                .ignoredParameterTypes();
//    }

    private ApiInfo apiInfo1(){
        return new ApiInfoBuilder()
                .title("用户信息管理API")
                .description("") .title("用户信息管理API文档")
                .description("用户信息管理接口文档说明")
                .contact(new Contact("用户管理开发人员", "http://www.example.com/", "developer@example.com"))
                .version("1.0")
                .build();
    }

}

